﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ath2011_sql_WPF
{
    class txt_to_string
    {
        // public string[] text;
        string filename;
        string podzial;

        public txt_to_string(string filename1, string podzial = "\n")
        {
            this.filename = filename1;
            this.podzial = podzial;
            // convert();
        }

        public string[] convert()
        {
            string[] text;
            string filename = this.filename;
            StreamReader sr1 = new StreamReader(filename);
            string s1;
            //string podzial = "\n";
            int a = 0;

            while ((s1 = sr1.ReadLine()) != null)
            {
                string[] s2 = s1.Split(new string[] { podzial }, StringSplitOptions.None);
                a++;
            }

            text = new string[a];

            sr1 = new StreamReader(filename);

            for (int i = 0; (s1 = sr1.ReadLine()) != null; i++)
            {

                string[] s2 = s1.Split(new string[] { podzial }, StringSplitOptions.None);

                for (int j = 0; j < s2.Length; j++)
                {
                    text[i] = s2[j];
                }
            }
            sr1.Close();

            return text;
        }
    }
}
